<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  Class: Ability
  
    &mdash; Documentation by YARD 0.8.2.1
  
</title>

  <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />

  <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  hasFrames = window.top.frames.main ? true : false;
  relpath = '';
  framesUrl = "frames.html#!" + escape(window.location.href);
</script>


  <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="js/app.js"></script>


  </head>
  <body>
    <div id="header">
      <div id="menu">
  
    <a href="_index.html">Index (A)</a> &raquo;
    
    
    <span class="title">Ability</span>
  

  <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  
    <a class="full_list_link" id="class_list_link"
        href="class_list.html">
      Class List
    </a>
  
    <a class="full_list_link" id="method_list_link"
        href="method_list.html">
      Method List
    </a>
  
    <a class="full_list_link" id="file_list_link"
        href="file_list.html">
      File List
    </a>
  
</div>
      <div class="clear"></div>
    </div>

    <iframe id="search_frame"></iframe>

    <div id="content"><h1>Class: Ability
  
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">Object</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">Ability</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
      <dt class="r2">Includes:</dt>
      <dd class="r2">CanCan::Ability</dd>
      
    
  
  
  
    <dt class="r1 last">Defined in:</dt>
    <dd class="r1 last">lib/ability.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    

  </div>
</div>
<div class="tags">
  
<p class="tag_title">Author:</p>
<ul class="author">
  
    <li>
      
      
      
      
        
        <div class='inline'><p>
Zamith
</p>
</div>
      
    </li>
  
</ul>

</div>






  
    <h2>
      Instance Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#admin-instance_method" title="#admin (instance method)">- (Object) <strong>admin</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Defines the permissions on a user with the role of admin As this is a super
admin that can do anything, it does not need to inherit from member.
</p>
</div></span>
  
</li>

      
        <li class="protected ">
  <span class="summary_signature">
    
      <a href="#generate_conditions_hash-instance_method" title="#generate_conditions_hash (instance method)">- (Object) <strong>generate_conditions_hash</strong>(permission) </a>
    

    
  </span>
  
  
  
  <span class="note title protected">protected</span>
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="protected ">
  <span class="summary_signature">
    
      <a href="#handle_permission-instance_method" title="#handle_permission (instance method)">- (Object) <strong>handle_permission</strong>(permission) </a>
    

    
  </span>
  
  
  
  <span class="note title protected">protected</span>
  
  
  

  
    <span class="summary_desc"><div class='inline'></div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#initialize-instance_method" title="#initialize (instance method)">- (Ability) <strong>initialize</strong>(user) </a>
    

    
  </span>
  
  
    <span class="note title constructor">constructor</span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Defines the permissions for a user wich is not logged in or if it is, calls
the corresponding method to its role.
</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#member-instance_method" title="#member (instance method)">- (Object) <strong>member</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>
Defines the permissions on a user with the role of member.
</p>
</div></span>
  
</li>

      
    </ul>
  


  <div id="constructor_details" class="method_details_list">
  <h2>Constructor Details</h2>
  
    <div class="method_details first">
  <h3 class="signature first" id="initialize-instance_method">
  
    - (<tt><span class='object_link'><a href="" title="Ability (class)">Ability</a></span></tt>) <strong>initialize</strong>(user) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>
Defines the permissions for a user wich is not logged in or if it is, calls
the corresponding method to its role
</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>user</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="Citygate/User.html" title="Citygate::User (class)">Citygate::User</a></span></tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>
the current user
</p>
</div>
      
    </li>
  
</ul>


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


8
9
10
11
12
13
14
15
16
17
18
19
20
21</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ability.rb', line 8</span>

<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_user'>user</span><span class='rparen'>)</span>
  <span class='comment'># This runs only once
</span>  <span class='cvar'>@@permissions</span> <span class='op'>||=</span> <span class='const'>Citygate</span><span class='op'>::</span><span class='const'>Permission</span><span class='period'>.</span><span class='id identifier rubyid_load_all'>load_all</span>

  <span class='ivar'>@user</span> <span class='op'>=</span> <span class='id identifier rubyid_user'>user</span> <span class='op'>||</span> <span class='const'>Citygate</span><span class='op'>::</span><span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='comment'># guest user (not logged in)
</span>
  <span class='cvar'>@@permissions</span><span class='lbracket'>[</span><span class='symbol'>:guest</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_permission'>permission</span><span class='op'>|</span>
    <span class='id identifier rubyid_handle_permission'>handle_permission</span> <span class='id identifier rubyid_permission'>permission</span>
  <span class='kw'>end</span>

  <span class='kw'>if</span> <span class='ivar'>@user</span><span class='period'>.</span><span class='id identifier rubyid_role'>role</span>
    <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='ivar'>@user</span><span class='period'>.</span><span class='id identifier rubyid_role'>role</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span><span class='rparen'>)</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
  
</div>


  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>

    
      <div class="method_details first">
  <h3 class="signature first" id="admin-instance_method">
  
    - (<tt>Object</tt>) <strong>admin</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>
Defines the permissions on a user with the role of admin As this is a super
admin that can do anything, it does not need to inherit from member
</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


33
34
35
36
37
38</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ability.rb', line 33</span>

<span class='kw'>def</span> <span class='id identifier rubyid_admin'>admin</span>
  <span class='comment'>#member
</span>  <span class='cvar'>@@permissions</span><span class='lbracket'>[</span><span class='symbol'>:admin</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_permission'>permission</span><span class='op'>|</span>
    <span class='id identifier rubyid_handle_permission'>handle_permission</span> <span class='id identifier rubyid_permission'>permission</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="generate_conditions_hash-instance_method">
  
    - (<tt>Object</tt>) <strong>generate_conditions_hash</strong>(permission)  <span class="extras">(protected)</span>
  

  

  
</h3><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


58
59
60
61
62
63
64
65
66
67
68
69
70
71</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ability.rb', line 58</span>

<span class='kw'>def</span> <span class='id identifier rubyid_generate_conditions_hash'>generate_conditions_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_permission'>permission</span><span class='rparen'>)</span>
  <span class='id identifier rubyid_user'>user</span> <span class='op'>=</span> <span class='ivar'>@user</span>
  <span class='id identifier rubyid_conditions_hash'>conditions_hash</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
  <span class='kw'>if</span> <span class='id identifier rubyid_permission'>permission</span><span class='period'>.</span><span class='id identifier rubyid_conditions'>conditions</span>
    <span class='id identifier rubyid_permission'>permission</span><span class='period'>.</span><span class='id identifier rubyid_conditions'>conditions</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>,</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_condition'>condition</span><span class='op'>|</span>
      <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span><span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_condition'>condition</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>#</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
      <span class='id identifier rubyid_conditions_hash'>conditions_hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_instance_eval'>instance_eval</span> <span class='id identifier rubyid_value'>value</span>
    <span class='kw'>end</span>
    
    <span class='id identifier rubyid_conditions_hash'>conditions_hash</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='label'>id:</span> <span class='id identifier rubyid_permission'>permission</span><span class='period'>.</span><span class='id identifier rubyid_subject_id'>subject_id</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_permission'>permission</span><span class='period'>.</span><span class='id identifier rubyid_subject_id'>subject_id</span>
  <span class='kw'>end</span>
  
  <span class='kw'>return</span> <span class='id identifier rubyid_conditions_hash'>conditions_hash</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="handle_permission-instance_method">
  
    - (<tt>Object</tt>) <strong>handle_permission</strong>(permission)  <span class="extras">(protected)</span>
  

  

  
</h3><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ability.rb', line 42</span>

<span class='kw'>def</span> <span class='id identifier rubyid_handle_permission'>handle_permission</span><span class='lparen'>(</span><span class='id identifier rubyid_permission'>permission</span><span class='rparen'>)</span>
  <span class='kw'>if</span> <span class='id identifier rubyid_permission'>permission</span><span class='period'>.</span><span class='id identifier rubyid_subject_id'>subject_id</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
    <span class='kw'>begin</span>
      <span class='id identifier rubyid_can'>can</span> <span class='id identifier rubyid_permission'>permission</span><span class='period'>.</span><span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='comma'>,</span> <span class='id identifier rubyid_permission'>permission</span><span class='period'>.</span><span class='id identifier rubyid_subject_class'>subject_class</span><span class='period'>.</span><span class='id identifier rubyid_constantize'>constantize</span><span class='comma'>,</span> <span class='id identifier rubyid_generate_conditions_hash'>generate_conditions_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_permission'>permission</span><span class='rparen'>)</span>
    <span class='kw'>rescue</span>
      <span class='id identifier rubyid_can'>can</span> <span class='id identifier rubyid_permission'>permission</span><span class='period'>.</span><span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='comma'>,</span> <span class='id identifier rubyid_permission'>permission</span><span class='period'>.</span><span class='id identifier rubyid_subject_class'>subject_class</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='comma'>,</span> <span class='id identifier rubyid_generate_conditions_hash'>generate_conditions_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_permission'>permission</span><span class='rparen'>)</span>
    <span class='kw'>end</span>
  <span class='kw'>else</span>
    <span class='kw'>begin</span>
      <span class='id identifier rubyid_can'>can</span> <span class='id identifier rubyid_permission'>permission</span><span class='period'>.</span><span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='comma'>,</span> <span class='id identifier rubyid_permission'>permission</span><span class='period'>.</span><span class='id identifier rubyid_subject_class'>subject_class</span><span class='period'>.</span><span class='id identifier rubyid_constantize'>constantize</span><span class='comma'>,</span> <span class='id identifier rubyid_generate_conditions_hash'>generate_conditions_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_permission'>permission</span><span class='rparen'>)</span>
    <span class='kw'>rescue</span>
      <span class='id identifier rubyid_can'>can</span> <span class='id identifier rubyid_permission'>permission</span><span class='period'>.</span><span class='id identifier rubyid_action'>action</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='comma'>,</span> <span class='id identifier rubyid_permission'>permission</span><span class='period'>.</span><span class='id identifier rubyid_subject_class'>subject_class</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='comma'>,</span> <span class='id identifier rubyid_generate_conditions_hash'>generate_conditions_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_permission'>permission</span><span class='rparen'>)</span>
    <span class='kw'>end</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="member-instance_method">
  
    - (<tt>Object</tt>) <strong>member</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    <p>
Defines the permissions on a user with the role of member
</p>


  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


24
25
26
27
28</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/ability.rb', line 24</span>

<span class='kw'>def</span> <span class='id identifier rubyid_member'>member</span>
  <span class='cvar'>@@permissions</span><span class='lbracket'>[</span><span class='symbol'>:member</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_permission'>permission</span><span class='op'>|</span>
    <span class='id identifier rubyid_handle_permission'>handle_permission</span> <span class='id identifier rubyid_permission'>permission</span>
  <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>

    <div id="footer">
  Generated on Thu Sep 20 15:56:37 2012 by
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.8.2.1 (ruby-1.9.2).
</div>

  </body>
</html>